class TodoCommentsController < ApplicationController
  # GET /todo_comments
  # GET /todo_comments.xml
  def index
    @comments = TodoComment.find(:all)
    render :update do |page|
      page.update_html 'comments_' + params[:id].to_s,:partial=>'todo_comments/comments_list'
    end
  end

  # GET /todo_comments/1
  # GET /todo_comments/1.xml
  def show
    @todo_comment = TodoComment.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @todo_comment }
    end
  end

  # GET /todo_comments/new
  # GET /todo_comments/new.xml
  def new
    @todo_comment = TodoComment.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @todo_comment }
    end
  end

  # GET /todo_comments/1/edit
  def edit
    @todo_comment = TodoComment.find(params[:id])
  end

  # POST /todo_comments
  # POST /todo_comments.xml
  def create
    @todo_comment = TodoComment.new(params[:todo_comment])

    respond_to do |format|
      if @todo_comment.save
        flash[:notice] = 'TodoComment was successfully created.'
        format.html { redirect_to(@todo_comment) }
        format.xml  { render :xml => @todo_comment, :status => :created, :location => @todo_comment }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @todo_comment.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /todo_comments/1
  # PUT /todo_comments/1.xml
  def update
    @todo_comment = TodoComment.find(params[:id])

    respond_to do |format|
      if @todo_comment.update_attributes(params[:todo_comment])
        flash[:notice] = 'TodoComment was successfully updated.'
        format.html { redirect_to(@todo_comment) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @todo_comment.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /todo_comments/1
  # DELETE /todo_comments/1.xml
  def destroy
    @todo_comment = TodoComment.find(params[:id])
    @todo_comment.destroy

    respond_to do |format|
      format.html { redirect_to(todo_comments_url) }
      format.xml  { head :ok }
    end
  end
end
